package com.xianggu.designMode.chainMethod.demo03.impl;

import com.xianggu.designMode.chainMethod.demo03.Order;
import com.xianggu.designMode.chainMethod.demo03.OrderHandler;
import com.xianggu.designMode.chainMethod.demo03.OrderResult;

// 库存校验处理器
public class InventoryHandler extends OrderHandler {
    @Override
    protected OrderResult doHandle(Order order) {
        if (checkStock(order.getItemCount())) {
            return OrderResult.success();
        }
        return OrderResult.fail("库存不足", "InventoryCheck");
    }

    private boolean checkStock(int required) {
        // 模拟库存检查逻辑
        return required <= 10;
    }
}